﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Cau1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class Cau1 : Window
    {
        int a, b;
        public Cau1()
        {
            InitializeComponent();
        }

        private void thoat_Click(object sender, RoutedEventArgs e)
        {
            
       
           MessageBoxResult result = MessageBox.Show("Bạn có muốn thoát không?", "Thông Báo", MessageBoxButton.YesNo, MessageBoxImage.Warning);
           if (result == MessageBoxResult.Yes)
           {
               this.Close();
           }
        }

        private void reset_Click(object sender, RoutedEventArgs e)
        {
            nhapa.Text = "";
            nhapb.Text = "";
            kq.Text = "";
        }

        private void cong_Click(object sender, RoutedEventArgs e)
        {
            a = Convert.ToInt32(nhapa.Text);
            b = Convert.ToInt32(nhapb.Text);
            kq.Text = Convert.ToString(a + b);
        }

        private void tru_Click(object sender, RoutedEventArgs e)
        {
            a = Convert.ToInt32(nhapa.Text);
            b = Convert.ToInt32(nhapb.Text);
            kq.Text = Convert.ToString(a - b);
        }

        private void nhan_Click(object sender, RoutedEventArgs e)
        {
            a = Convert.ToInt32(nhapa.Text);
            b = Convert.ToInt32(nhapb.Text);
            kq.Text = Convert.ToString(a * b);
        }

        private void chia_Click(object sender, RoutedEventArgs e)
        {
            float a = float.Parse(nhapa.Text);
            float b = float.Parse(nhapb.Text);
            if (b == 0)
                MessageBox.Show("Không chia hết cho 0");
            else
                kq.Text = Convert.ToString(a / b);
        }
    }
}
